const foo = function () {
  console.log('༼ つ ◕_◕ ༽つ Hi Rollup')
}

export const addNumber = function (...numberArgs) {
  let result = 0
  if (numberArgs.length < 1) return result
  numberArgs.forEach((num) => {
    if (typeof num !== 'number')
      throw new Error('please transfer current number')
    result += num
  })
  return result
}

// 打包js高级语法看看（）
export class FireEvent {
  constructor() {
    this.eventObj = []
    this.starting = true
  }

  fire(data) {
    if (!this.starting) return
    for (const obj of this.eventObj) {
      obj.fun(data)
    }
  }

  on(fun) {
    if (typeof fun === 'function') {
      const obj = { fun }
      this.eventObj.push(obj)
      return () => {
        const index = this.eventObj.indexOf(obj)
        if (index >= 0) this.eventObj.splice(index, 1)
      }
    }
    return () => {}
  }

  start() {
    this.starting = true
  }
  stop() {
    this.starting = false
  }
}

export default {
  foo
}
